//************************************************************
//    > File Name: identical-binary-tree.cpp
//    > Author: davis
//    > Mail:  
//    > Created Time: 2017年03月24日 15:12:39
//***********************************************************
//lintcode #469
#include<bits/stdc++.h>
using namespace std;
class TreeNode{
	public:
		int val;
		TreeNode *left,*right;
		TreeNode (int val=-1){
			this->val=val;
			this->left=this->right=NULL;
		}
};
bool isIdentical(TreeNode *a,TreeNode *b){
	if(!a && !b)
		return true;
	if(a && b)
		return (a->val==b->val && isIdentical(a->left,b->left) && isIdentical(a->right,b->right));
	return false;
}
int main(){
	TreeNode *a=new TreeNode[3];
	a[0].val=1;
	a[1].val=2;
	a[3].val=3;
	a[0].left=&a[1];
	a[0].right=&a[2];
	TreeNode *b=new TreeNode[3];
	b[0].val=1;
	b[1].val=2;
	b[3].val=3;
	b[0].left=&b[1];
	b[0].right=&b[2];
	cout<<isIdentical(a,b)<<endl;
	return 0;
}
